const express=require('express');;
const app=express();
const bodyParser=require('body-parser');

app.use(bodyParser.json());

app.post('/api/login',(req,res)=>{
    
    const {username,password}=req.body;
    if(username==='admin' && password==='123456'){
        res.json({token:'example-token'});
    }
    else{
        res.status(401).json({message:'用户名或密码错误'}); //401 unauthorized
    }
});
const port=3000;
app.listen(port,()=>{
    console.log(`Server is running on port ${port}`);
})